home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
F1 Licenseware
/
F1 Licenseware - Volume 1.iso
/
disks
/
050a.dms
/
050a.adf
/
TEXTS
/
chapter21.txt
< prev
next >
Wrap
Text File
|
1992-02-26
|
5KB
|
96 lines
The Absolute Beginners Guide To Amos
-------------------------------------
Chapter Twenty One
-------------------
I am now going to attempt to explain the mysteries of the SHIFT command.
It's another one of those commands that are quite simple in practice but
difficult to explain in theory so I won't go on about it for too long.
Example21.Amos contains the following code:
HIDE ON
UNPACK 10 TO 0
SHIFT UP 1,1,31,1
WAIT KEY
EDIT
What this amazingly small piece of code achieves is an absolutely stunning
scrolling starfield. Please take a look at it now otherwise you will
probably not understand what I am droning on about.
Had a look? Good wasn't it? This is how it was done:
Stored in bank 10 is a SPACKed 32 colour picture of a black screen with
some white dots put on it. You can see this picture by going into direct
mode (Escape) and typing in UNPACK 10 TO 0. If the stars are still moving
then type in SHIFT OFF.
Back to the program. Amos unpacks this screen and displays it then executes
the SHIFT command which I will now do a breakdown of.
SHIFT UP delay,firstcolour,lastcolour,flag
------------------------------------------
What the SHIFT command does is to rotate the colours in the picture,
swapping them around starting with firstcolour and ending with lastcolour
which of course you can change to suit your requirements. The delay is just
like the WAIT command, it is measured in 50ths of a second. Try changing the
value of delay (the first number) to see it's effect. The flag indicates
the type of colour rotation. There are two types the one we are using (the
number 1 on the end) just continues cycling the colours until instructed
otherwise. If we changed this to a 0 the cycle would only last a short while
as Amos would be instructed not to save and replace the colour after
shifting. The best way to see this is to try it.
The firstcolour is the first colour number you want to be shifted in your
picture and lastcolour is obviously the last. Try changing them also.
All Shift operations can be instantly killed with the SHIFT OFF command.
The only other SHIFT command is SHIFT DOWN which reverses the direction
of the colour shifting. This would make our example stars fly to the left
instead of the right.
As you are probably bored of the self test quizzes we will now move on to
doing simple programming projects.
Remember I told you about the joystick commands in chapter 20? Well why
not try to write a small routine to control the left/right movement of the
stars? My idea of a solution in contained in Example22.Amos.
Another interrupt driven command you may find interesting is the FLASH
command. We can select any colour and make that FLASH in any colour sequence
at any speed we want. Load up Example21_1.Amos for a VERY simple example of
the FLASH command. I have purposely made it simple and boring so you can
add experimentation to it. But first let us see how it works.
Let us presume you have drawn a BOX on the screen as part of a menu system.
When the user clicks the mouse inside the box you want the box to FLASH to
indicate to the user that the box is now selected. Let us say we drew the
box using INK 6, like this:
INK 6
BOX 100,150 TO 200,250
We would set up a mouse zone (as described in an earlier chapter) and test
for a mouse click. If the mouse was clicked and the pointer was inside our
box we could then use FLASH to make the box pulsate, like this:
FLASH 6,"(FFF,10)(000,10)"
Remember the ANIM command? It is a similar set up. The 6 is the colour we
want to FLASH, this applies to PEN as well as INK so it would work on
ANYTHING on the screen that is in colour 6.
The FFF is the RGB value of the first part of the FLASH sequence. FFF is
white. The 10 that follows is a delay in 50ths of a second just like in the
SHIFT command. The second part of our FLASH sequence is 000 which is black
also with a 10 50ths delay. So our box will FLASH black and white until we
tell it not to. To do that we use FLASH OFF. And that is all there is to it
really. You can of course change the colour values and delay times to
anything you want and best of all you can have up to 20 sequences in a
single FLASH command, just keep adding them inside the quotes. Load up the
example program and have a jolly good experimentation session and see what
you can come up with.
End of Chapter 21
^^^^^^^^^^^^^^^^^